#!/bin/bash
##  awk_df.sh 2022-09-06

## linux 命令
# df -lh  查看当前机器挂载的各个磁盘的空间大小
# df -h   显示已经挂载的分区列表

# $ ./awk_df.sh 
# Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk1s5s1 466Gi 21Gi 64Gi 25% 553788 4882923132 0% /
# ----------------------------
# /dev/disk1s5s1 466Gi 21Gi 64Gi 25% 553788 4882923132 0% /
# ----------------------------
# 466Gi 25%

# Ubuntu20.04
# $ ./awk_df.sh
# Filesystem Size Used Avail Use% Mounted on /dev/sda5 20G 8.6G 9.5G 48% /
# ----------------------------
# /dev/sda5 20G 8.6G 9.5G 48% /
# ----------------------------
# 20G 48%


disk_info=`df -lh / `
echo $disk_info
echo '----------------------------'

disk_info=`df -h / | grep  /`
echo $disk_info  #/dev/disk1s5s1 466Gi 21Gi 64Gi 25% 553788 4882923132 0% /
echo '----------------------------'

disk_size=`df -lh /| grep /| awk '{print $2, $5}'`
echo $disk_size #466Gi 25%
     
